//
//  HomeButton.m
//  ALS3.0
//
//  Created by guomianxiang on 16/12/23.
//  Copyright © 2016年 guomianxiang. All rights reserved.
//

#import "HomeButton.h"
#import "LGtools.h"

@interface HomeButton ()

@property (weak, nonatomic) UILabel *englishLabel;

@end

@implementation HomeButton

- (void)setHighlighted:(BOOL)highlighted {
    [super setHighlighted:highlighted];
    if (highlighted) {
        self.englishLabel.textColor = [UIColor lightGrayColor];
    }else {
        self.englishLabel.textColor = [UIColor whiteColor];
    }
}

- (void)layoutSubviews {
    [super layoutSubviews];
    //添加English btn

    if ([self.currentTitle isEqualToString:@"门禁控制器"]) {
        self.englishLabel.text = @"Access control";
    }
    if ([self.currentTitle isEqualToString:@"视频门禁"]) {
        self.englishLabel.text = @"Video control";
    }
    if ([self.currentTitle isEqualToString:@"进出记录"]) {
        self.englishLabel.text = @"Passing recorde";
    }
    if ([self.currentTitle isEqualToString:@"查看更多"]) {
        self.englishLabel.text = @"Search more";
    }
    
    [self.englishLabel sizeToFit];
    
    
    [self setTitleColor:kColorFromRGB(0x3fedeb) forState:(UIControlStateHighlighted)];
    
    CGRect frame = self.imageView.frame;
    frame.origin.x = 12;
    self.imageView.frame = frame;
    
    frame = self.titleLabel.frame;
    frame.origin.x = CGRectGetMaxX(self.imageView.frame) + 15;
    self.titleLabel.frame = frame;

    frame = self.englishLabel.frame;
    frame.origin.x = self.titleLabel.frame.origin.x;
    frame.origin.y = CGRectGetMaxY(self.titleLabel.frame);
    
    self.englishLabel.frame = frame;
}

- (UILabel *)englishLabel {
    if (_englishLabel == nil) {
        UILabel *lab = [[UILabel alloc]init];
        [self addSubview:lab];
        lab.textAlignment = NSTextAlignmentLeft;
        lab.font = [UIFont systemFontOfSize:10];
        lab.textColor = [UIColor whiteColor];
        _englishLabel = lab;
    }
    return _englishLabel;
}

@end
